package cn.kgc.sm.service;

import cn.kgc.sm.entity.Student;
import cn.kgc.sm.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: mosin
 * @version: v1.0  2022/4/27
 */
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    public void  print(){
        System.out.println("studentMapper = " + studentMapper);
    }

    @Override
    public Student findOne(int id) {
        Student student = studentMapper.selectById(id);
        return student;
    }

    @Override
    public List<Student> findAll() {
        return studentMapper.selectAll();
    }

    @Override
    public boolean saveStudent(Student student) {
        int i = studentMapper.addStudent(student);
        return i>0;
    }

    @Override
    public boolean updateStudent(Student student) {
        int line =   studentMapper.updateStudent(student);
        return line>0;
    }

    @Override
    public boolean delStudent(int id) {
        int line = studentMapper.delStudent(id);
        return line>0;
    }

}
